<template>
  <div class="list">
    <div class="listItem wow fadeInLeft" :data-wow-delay="index*0.3+'s'" v-for="(item,index) in list" :key="index">
      <item :item="item"></item>
    </div>
  </div>
</template>

<script>
import numcard from "@/components/numcard/numcard.vue";
import item from './components/item.vue'
import {airConditionerRealtimeMonitoring} from "@/api/api/LargeScreenData.js";


export default {
  data() {
    return {
      list: [],
      dataInterval: null,
    }
  },
  components: {numcard, item},
  mounted() {
    this.getData(); // Initial fetch
    this.dataInterval = setInterval(this.getData, 30000); // Every 30 seconds
  },
  beforeDestroy() {
    clearInterval(this.dataInterval); // Clear the interval when the component is destroyed
  },
  methods: {
    async getData() {
      try {
        const res = await airConditionerRealtimeMonitoring();
        this.list = res.data
      } catch (err) {
        console.error(err);
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.list {
  width: 100%;
  position: relative;
  height: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  flex-direction: row;
  align-content: flex-start;

  .listItem {
    width: calc(50% - 20px);
    margin: 15px 10px;
    height: calc(50% - 30px);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;

    .listIteml {
      width: 54px;
      height: 54px;
      background: url("./assets/iconbg.png");
      background-size: 100% 100%;
      margin-left: 13px;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;
      flex-shrink: 0;

      img {
        height: 40px;
      }
    }

    .listItemr {
      display: flex;
      justify-content: center;
      align-items: flex-start;
      flex-wrap: nowrap;
      flex-direction: column;
      align-content: flex-start;
      width: calc(100% - 100px);
      position: relative;
      height: 100%;
      margin-left: 11px;

      .title {
        font-size: 14px;
        font-family: AlibabaPuHuiTi;
        font-weight: 400;
        color: #B4C8E3;
      }

      :deep(.numBody) {
        height: 34px;

        .real-time-num {
          width: auto;
          font-size: 28px;
          overflow: hidden;
          font-family: PangMenZhengDao !important;
          font-weight: 400;
          color: #36D0F2;
          margin-left: 0;
        }
      }
    }
  }
}
</style>
